package org.jsola.hr.helper;

import org.jsola.common.SafeKit;
import org.jsola.hr.dto.EmpSocBackRecordAccountAddDTO;
import org.jsola.hr.dto.EmpSocBackRecordAccountUpdateDTO;
import org.jsola.hr.entity.EmpSocBackRecordAccountDO;
import org.jsola.hr.query.EmpSocBackRecordAccountQuery;
import org.jsola.hr.service.IEmpSocBackRecordAccountService;
import org.jsola.hr.vo.EmpSocBackRecordAccountVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;

import java.math.BigDecimal;
import java.util.List;

import static org.jsola.hr.core.AbstractTest.SITE_ID;



/**
 * 社保回款账户
 *
 * @author zhr
 */
@Component
public class EmpSocBackRecordAccountTestHelper extends BaseTestHelper {
    
    @Autowired
    private IEmpSocBackRecordAccountService empSocBackRecordAccountService;

    /**
     * 生成add测试数据
     * @return EmpSocBackRecordAccountAddDTO
     */
    public EmpSocBackRecordAccountAddDTO getEmpSocBackRecordAccountAddDTO(){
        EmpSocBackRecordAccountAddDTO empSocBackRecordAccountAddDTO = new EmpSocBackRecordAccountAddDTO();
        empSocBackRecordAccountAddDTO.setEmpId(getRandomValue("varchar",32));
        empSocBackRecordAccountAddDTO.setAmount(SafeKit.getBigDecimal(getRandomValue("decimal",11)));
        return empSocBackRecordAccountAddDTO;
    }


    /**
     * 生成update测试数据
     * @return EmpSocBackRecordAccountUpdateDTO
     */
    public EmpSocBackRecordAccountUpdateDTO getEmpSocBackRecordAccountUpdateDTO(EmpSocBackRecordAccountVO empSocBackRecordAccountVO){
        return empSocBackRecordAccountService.selectDOById(empSocBackRecordAccountVO.getId(), SITE_ID).to(EmpSocBackRecordAccountUpdateDTO.class);
    }

    /**
     * 生成查询数据
     * @return EmpSocBackRecordAccountQuery
     */
    public EmpSocBackRecordAccountQuery getEmpSocBackRecordAccountQuery() {
        EmpSocBackRecordAccountQuery empSocBackRecordAccountQuery = new EmpSocBackRecordAccountQuery();
        List<EmpSocBackRecordAccountDO> empSocBackRecordAccountDOList = empSocBackRecordAccountService.list(new EmpSocBackRecordAccountDO(),SITE_ID);
        if (!CollectionUtils.isEmpty(empSocBackRecordAccountDOList)) {
            EmpSocBackRecordAccountDO empSocBackRecordAccountDO = empSocBackRecordAccountDOList.get(0);
            empSocBackRecordAccountQuery = empSocBackRecordAccountDO.to(EmpSocBackRecordAccountQuery.class);
        }
        return empSocBackRecordAccountQuery;
    }

    /**
     * 保存示例
     * @return EmpSocBackRecordAccountVO
     */
    public EmpSocBackRecordAccountVO saveEmpSocBackRecordAccountExample(){
        EmpSocBackRecordAccountAddDTO addDTO = this.getEmpSocBackRecordAccountAddDTO();
        EmpSocBackRecordAccountVO empSocBackRecordAccountVO = empSocBackRecordAccountService.save(addDTO,buildTokenUser());
        return empSocBackRecordAccountVO;
    }


}

